package com.ltsh.fim.common.impl;

import com.ltsh.fim.common.inf.MyDecoder;
import com.ltsh.fim.common.model.FimRequest;
import io.netty.buffer.ByteBuf;

public class MyDecoderImpl implements MyDecoder {
    public FimRequest decoding(ByteBuf byteBuf) {
        byte type = byteBuf.readByte();
        long requestId = byteBuf.readLong();
        int length = byteBuf.readInt();
        byte[] data = new byte[length];
        byteBuf.readBytes(data);
        FimRequest request = new FimRequest();
        request.setId(requestId);
        request.setType(type);
        request.setData(data);
        return request;
    }
}
